﻿using System;
using System.Collections.Generic;
using System.Text;

namespace daSyntaxAnalyser.SyntaxTree
{
    using daBase.Objects;

    public class BinaryExpressionElement : ExpressionElement
    {
        private TokenInfo type;
        private ExpressionElement left;
        private ExpressionElement right;

        public TokenInfo Type { get { return type; } set { type = value; } }
        public ExpressionElement Left { get { return left; } set { left = value; } }
        public ExpressionElement Right { get { return right; } set { right = value; } }

        public BinaryExpressionElement(TokenInfo Type, ExpressionElement Left, ExpressionElement Right, List<TokenInfo> Comments)
            : base(Left.StartInfo, Comments)
        {
            type = Type;
            left = Left;
            right = Right;
        }

        public override string ToString()
        {
            return string.Format("{0} {1} {2}", left, type.Text, right);
        }

        protected override IEnumerator<ISyntaxTreeElement> CreateEnumerator()
        {
            yield return left;
            yield return right;
        }
    }
}
